package main

import "fmt"

func main()  {
	s1 := []int {1,2,3,4,5,6,7,8,9,10}

	index := search(s1, 9)
	fmt.Println(index)




}

/*
顺序查找
*/
func search(s1 []int, num int) (index int)  {
	for i:=0; i<len(s1); i++ {
		if num == s1[i] {
			return i
		}
	}
	return -1
}


/*
二分查找
*/
func searchInBinary(s1 []int, num int) (index int)  {
	low := 0
	high := len(s1)-1
	mid := (low + high) / 2


	if num == s1[mid] {
		return mid
	} else if num > s1[mid] {
		low = mid + 1
	} else {
		high = mid - 1
	}
	mid = (low + high) / 2




	for low < high {

	}


}

